package store.lunangangster.bpmn.converter;

import javax.xml.stream.XMLStreamReader;
import store.lunangangster.bpmn.converter.parser.MessageEventDefinitionParser;
import store.lunangangster.bpmn.model.BaseElement;
import store.lunangangster.bpmn.model.BoundaryEvent;
import store.lunangangster.bpmn.model.BpmnModel;

public class BoundaryEventConverter extends
    EventConverter {

  public BoundaryEventConverter() {
    addChildElementParser(new MessageEventDefinitionParser());
  }

  @Override
  protected BaseElement convertToElement(XMLStreamReader xsr, BpmnModel model) throws Exception {
    BoundaryEvent boundaryEvent = new BoundaryEvent();

    String attachedToRef = xsr.getAttributeValue(null, ATTRIBUTE_COMMON_REF);
    boundaryEvent.setAttachedToRef(attachedToRef);

    parseChildElement(xsr, boundaryEvent, getTargetName(), model);

    return boundaryEvent;
  }

  @Override
  public String getTargetName() {
    return ELEMENT_EVENT_BOUNDARY;
  }
}
